package org.familysearch.fsapi.gwt.common.client;

import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.familysearch.fsapi.gwt.common.client.entities.Gender;
import org.familysearch.fsapi.gwt.common.client.entities.Identifier;
import org.familysearch.fsapi.gwt.common.client.entities.Information;

import junit.framework.TestCase;

public class InformationTestCase extends TestCase {

	private Logger log;
	
	public InformationTestCase()
	{
		log = Logger.getLogger(this.getClass().getName());
	}
	
	public void test_Information001()
	{
		Information i1 = new Information();
		log.debug(i1);
		assertNotNull(i1);

	}
	
	public void test_Information002()
	{
		Information i = new Information(Gender.MALE);
		log.debug(i);
		assertEquals(i.getGender(), Gender.MALE);
		assertEquals(i.isLiving(), false);
	}	

	public void test_Information003()
	{
		Information i = new Information(Gender.FEMALE);
		log.debug(i);
		assertEquals(i.getGender(), Gender.FEMALE);
		assertEquals(i.isLiving(), false);		
	}	
	
	public void test_Information004()
	{
		Information i = new Information(Gender.UNKNOWN);
		log.debug(i);
		assertEquals(i.getGender(), Gender.UNKNOWN);
		assertEquals(i.isLiving(), false);		
	}
	
	public void test_Information005()
	{
		Information i = new Information(Gender.MALE, true);
		log.debug(i);
		assertEquals(i.getGender(), Gender.MALE);
		assertEquals(i.isLiving(), true);		
	}	
	
	public void test_Information006()
	{
		Information i = new Information(Gender.MALE, false);
		log.debug(i);
		assertEquals(i.getGender(), Gender.MALE);
		assertEquals(i.isLiving(), false);		
	}
	
	public void test_Information007()
	{
		Information i = new Information(Gender.FEMALE, true);
		log.debug(i);
		assertEquals(i.getGender(), Gender.FEMALE);
		assertEquals(i.isLiving(), true);		
	}		
	
	public void test_Information008()
	{
		Information i = new Information(Gender.FEMALE, false);
		log.debug(i);
		assertEquals(i.getGender(), Gender.FEMALE);
		assertEquals(i.isLiving(), false);		
	}		
	
	public void test_Information009()
	{
		Information i = new Information(Gender.UNKNOWN, true);
		log.debug(i);
		assertEquals(i.getGender(), Gender.UNKNOWN);
		assertEquals(i.isLiving(), true);		
	}	
	
	public void test_Information010()
	{
		Information i = new Information(Gender.UNKNOWN, false);
		log.debug(i);
		assertEquals(i.getGender(), Gender.UNKNOWN);
		assertEquals(i.isLiving(), false);
	}
	
	public void test_Information011()
	{
		
		Information i = new Information(Gender.MALE, false, null);
		log.debug(i);
		assertEquals(i.getAlternateIds(), null);
	}	
	
	public void test_Information012()
	{
		
		ArrayList<Identifier> ids = new ArrayList<Identifier>();
		Identifier id = new Identifier();
		ids.add(id);
		
		Information i = new Information(Gender.MALE, false, ids);
		log.debug(i);
		assertEquals(i.getAlternateIds().size(), 1);
	}	
	
	public void test_Information013()
	{
		
		ArrayList<Identifier> ids = new ArrayList<Identifier>();
		Identifier id = new Identifier(Identifier.FSAPI);
		ids.add(id);
		
		Information i = new Information(Gender.MALE, false, ids);
		log.debug(i);
		assertEquals(i.getAlternateIds().get(0).getType(), Identifier.FSAPI);
	}	
	
	public void test_Information014()
	{
		
		ArrayList<Identifier> ids = new ArrayList<Identifier>();
		Identifier id = new Identifier(Identifier.AFN);
		ids.add(id);
		
		Information i = new Information(Gender.MALE, false, ids);
		log.debug(i);
		assertEquals(i.getAlternateIds().get(0).getType(), Identifier.AFN);
	}	
	
	public void test_Information015()
	{
		
		ArrayList<Identifier> ids = new ArrayList<Identifier>();
		Identifier id = new Identifier(Identifier.GEDCOM);
		ids.add(id);
		
		Information i = new Information(Gender.MALE, false, ids);
		log.debug(i);
		assertEquals(i.getAlternateIds().get(0).getType(), Identifier.GEDCOM);
	}
	
	public void test_Information016()
	{
		
		ArrayList<Identifier> ids = new ArrayList<Identifier>();
		Identifier id = new Identifier(Identifier.OTHER);
		ids.add(id);
		
		Information i = new Information(Gender.MALE, false, ids);
		log.debug(i);
		assertEquals(i.getAlternateIds().get(0).getType(), Identifier.OTHER);
	}	
	
	public void test_Information017()
	{
		
		ArrayList<Identifier> ids = new ArrayList<Identifier>();
		Identifier id1 = new Identifier(Identifier.AFN);
		Identifier id2 = new Identifier(Identifier.FSAPI);
		Identifier id3 = new Identifier(Identifier.GEDCOM);
		Identifier id4 = new Identifier(Identifier.OTHER);
		ids.add(id1);
		ids.add(id2);
		ids.add(id3);
		ids.add(id4);
		
		Information i = new Information(Gender.MALE, false, ids);
		log.debug(i);
		
		assertEquals(i.getAlternateIds().size(), 4);
		assertEquals(i.getAlternateIds().get(0).getType(), Identifier.AFN);
		assertEquals(i.getAlternateIds().get(1).getType(), Identifier.FSAPI);
		assertEquals(i.getAlternateIds().get(2).getType(), Identifier.GEDCOM);
		assertEquals(i.getAlternateIds().get(3).getType(), Identifier.OTHER);
	}	
	
}
